﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class InspectorTool : Editor {

    [MenuItem("Tools/Component/Fold All")]
    public static void FoldAll(MenuCommand command)
    {
        ActiveEditorTracker editorTracker = ActiveEditorTracker.sharedTracker;
        Editor[] editors = editorTracker.activeEditors;

        bool areAllFolded = true;
        for (int i = 1; i < editors.Length; i++)
        {
            if (editorTracker.GetVisible(i) != 0)
            {
                areAllFolded = false;
                break;
            }
        }

        for (int i = 1; i < editors.Length; i++)
        {
            editorTracker.SetVisible(i, areAllFolded ? 1 : 0);
        }
    }
}
